﻿using System;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Data.EntityClient;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Runtime.Serialization;

namespace Accounts
{
    public partial class tblTransactionDetail
    {
        public decimal CreditAmount
        {
            get { return (this.TransactionDetailTypeCode == "C") ? Amount : 0; }
        }

        public decimal DebitAmount
        {
            get { return (this.TransactionDetailTypeCode == "D") ? Amount : 0; }
        }
    }

    public partial class tblAccount
    {
        public decimal Balance
        {
            get
            {
                decimal amt = 0;
                foreach (tblTransactionDetail t in TransactionDetails)
                    amt += (t.TransactionDetailTypeCode == "C") ? t.Amount : 0 - t.Amount;
                return amt;
            }
        }
    }
}
